<!--2019/5/23 8:39. by soft-->
<#assign title="建议箱" advises='this'>
<#include 'header.ftl'>

<div class="layui-card">
  <div class="layui-card-header">
    <div class="card-title">
      学生建议箱
    </div>
    <div class="header-tools">
    </div>
  </div>
  <div class="layui-card-body">
    <table id="tables" lay-filter="tables"></table>
  </div>
</div>

<script>
  var methods, layerIndex;
  layui.use(['laytpl', 'table', 'layer', 'form', 'jquery'], function () {
    var table = layui.table;
    var layer = layui.layer;
    var $ = layui.$;

    table.render({
      elem: '#tables',
      method: 'post',
      url: '/api/advise/page',
      page: true,
      cols: [[
        {title: '序号', type: 'numbers'},
        {title: '姓名', field: 'name'},
        {
          title: '联系QQ', templet: function (s) {
            if (s.room) {
              return s.room.qq;
            }
            return ''
          }
        },
        {title: '内容', field: 'content'},
        {title: '时间', field: 'datetime'},
        {
          title: '操作', templet: function (s) {
            return '<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>';
          }, width: 85
        }
      ]],
      parseData: parseData
    }); // table

    methods = {
      del: function (nt) {
        layer.alert('确定删除该建议？', {title: '确定提示', icon: 3}, function (index) {
          $.post('/api/advise/del/' + nt.id, function (data) {
            layer.msg('删除成功!', {icon: 6, time: 1200})
            table.reload('tables')
          })
          layer.close(index)
        })
      }
    }

    // 事件
    table.on("tool(tables)", function (e) {
      methods[e.event](e.data, e.tr);
    });
  });
</script>

<#include 'footer.ftl'>